#include "EraserTool.h"



EraserTool::EraserTool()
{
    util = BrushUtilities::getInstance();

}

EraserTool *EraserTool::getInstance()
{
    static EraserTool* inst=0;
    if(!inst)inst = new EraserTool();
    inst->util = BrushUtilities::getInstance();
    return inst;
}

int EraserTool::getSize() {
    return util->size;
}

int EraserTool::getShape() {
    return util->shape;
}

int EraserTool::getHeight() {
    return util->height;
}

int EraserTool::getBreadth() {
    return util->breadth;
}

const vector< pair<string, set<vector3<int> > > >& EraserTool::getCustomShapes(){
    return util->customShapes;
}

string EraserTool::getType()
{
    return "brush";
}

Result EraserTool::setSize(int a){
    return util->setSize(a);
}
Result EraserTool::setSize(int s, int h, int b){
    return util->setSize(s, h, b);
}

Result EraserTool::setBreadth(int a){
    return util->setBreadth(a);
}

Result EraserTool::setHeight(int a){
    return util->setHeight(a);
}

Result EraserTool::setShape(int a){
    return util->setShape(a);
}

Result EraserTool::setAxis(FIXED_AXES axis, bool toFix){
    return util->setAxis(axis, toFix);
}

Result EraserTool::setShapeName(int identifier, string n){
    return util->setShapeName(identifier, n);
}

Result EraserTool::addShape(){
    return util->addShape();
}

Result EraserTool::deleteShape(int i){
    return util->deleteShape(i);
}


void EraserTool::display() {
    if (util->mouseMove)
        util->execute(util->DISPLAY_ERASE);

}


Result EraserTool::mouseEnterEvent(QEvent *event){
    return util->mouseEnterEvent(event);
}

Result EraserTool::mouseLeaveEvent(QEvent *event){
    return util->mouseLeaveEvent(event);
}


Result EraserTool::keyPressEvent(QKeyEvent *event){
    return util->keyPressEvent(event);
}

Result EraserTool::keyReleaseEvent(QKeyEvent *event){
    return util->keyReleaseEvent(event);
}

Result EraserTool::mouseMoveEvent(QMouseEvent *event)
{
    Result r = util->mouseMoveEvent(event);
    if (r.getResult()){
        if (event->buttons() & Qt::LeftButton){
            return util->execute(util->ERASE);
        }
    }
    return r;
}

Result EraserTool::mousePressEvent(QMouseEvent *event)
{
    if (event->buttons() & Qt::LeftButton) {
        if (util->mousePressEvent(event).getResult()) {
            return util->execute(util->ERASE);
        }
    }
    return Result(false);
}
